From 9444f1162ff40842afe1c2a01cf0a32db19a6376 Mon Sep 17 00:00:00 2001 From: real-zephex Date: Sat, 13 Apr 2024 09:42:25 +0530 Subject: feature added: anime history is now stored locally on the device. --- src/app/anime/[id]/buttons.jsx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/app/anime/[id]/buttons.jsx') diff --git a/src/app/anime/[id]/buttons.jsx b/src/app/anime/[id]/buttons.jsx index eac1884..dd49d6e 100644 --- a/src/app/anime/[id]/buttons.jsx +++ b/src/app/anime/[id]/buttons.jsx @@ -10,8 +10,10 @@ import { PlyrLayout, plyrLayoutIcons, } from "@vidstack/react/player/layouts/plyr"; +import { storeLocal } from "../history/storeData"; export default function Button({ data2: info }) { + const currentDate = new Date(); const [videoLink, setVideoLink] = useState(null); async function video(id) { @@ -20,10 +22,26 @@ export default function Button({ data2: info }) { alert("Sorry, but not links were found"); } else { setVideoLink(link); - console.log(videoLink); } } + function store_to_local(name, image, episode, id) { + let newData = { + name: name, + image: image, + episode: episode, + id: id, + type: "anime", + date: `${currentDate.getDate()}-${String( + currentDate.getMonth() + 1 + ).padStart(2, "0")}`, + time: `${currentDate.getHours()}:${String( + currentDate.getMinutes() + ).padStart(2, "0")}`, + }; + storeLocal(newData); + } + return (

Episodes:

@@ -38,6 +56,12 @@ export default function Button({ data2: info }) { event.target.style.backgroundColor = "var(--soft-purple)"; video(item.id); + store_to_local( + info.title, + info.image, + item.number, + info.id + ); }} > {item.number} -- cgit v1.2.3